﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Common.Utilities.Dispatcher;
using Workflows.Components.TextMining.Properties;

namespace Workflows.Components.TextMining.Ontologies
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class TermRelationComponent:WorkflowComponentBase
    {
        #region ctor
        /// <summary>
        /// 
        /// </summary>
        public TermRelationComponent():base()
        {
            this.ComponentActivityType = WorkflowActivityType.SimpleActivity;
            this.ComponentCategory = WorkflowComponentCategory.TextMining.ToString();
            this.ComponentName = "Lucene Indexer";
            this.Description = "Index full text using lucene";
            this.ComponentIcon = Resources.vdt80pui_1050;
            this.ComponentImage = Resources.SqlWb_10008;

            this._Instruction=new TermRelationInstruction(this.ComponentID, Guid.Empty, 
                string.Empty, string.Empty, string.Empty, new Dictionary<string, double>(), 
                0.3, 2.5, string.Empty, string.Empty, string.Empty, 
                string.Empty, string.Empty, string.Empty);
            this._Output=new TermRelationOutput(this.ComponentID,Guid.Empty);
        }
        #endregion

        #region Overrides of WorkflowComponentBase

        private TermRelationInstruction _Instruction;
        /// <summary>an object that encapsulate instruction settings.</summary>
        public override InstructionBase Instruction
        {
            get
            {
                return _Instruction;
            }
            set
            {
                _Instruction = (TermRelationInstruction) value;
            }
        }

        private TermRelationOutput _Output;
        /// <summary>an object to encapsulate output</summary>
        public override ResultBase Output
        {
            get
            {
                return _Output;
            }
            set
            {
                _Output = (TermRelationOutput) value;
            }
        }

        #endregion

        public override XmlNode Serialize(ref XmlDocument xDoc, ref XmlNode parentNode)
        {
            XmlNode xNode = base.Serialize(ref xDoc, ref parentNode);
            this.Instruction.Serialize(ref xDoc, ref xNode);
            return xNode;
        }

        public override WorkflowComponentBase Instantiate(XmlNode xNode)
        {
            TermRelationComponent component = (TermRelationComponent)base.Instantiate(xNode);
            component.Instruction = component.Instruction.Instantiate(xNode.SelectSingleNode("Instruction"));
            return component;
        }
    }
}
